﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace Songhay.Wpf.Mvvm.Views
{
    /// <summary>
    /// User Control View
    /// </summary>
    public partial class UserControlView : Window
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="UserControlView"/> class.
        /// </summary>
        public UserControlView()
        {
            InitializeComponent();

            this.OKButton.Click += (s, args) =>
            {
                this.Panel.Children.Clear();
                this.Close();
            };
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UserControlView"/> class.
        /// </summary>
        /// <param name="control">The control.</param>
        public UserControlView(UserControl control) : this()
        {
            if(control == null)
                throw new ArgumentNullException("control",
                    "The control to targetValues is null.");

            if((control.Height >= this.Height) || (control.Width >= this.Width))
            {
                this.Height *= 1.25;
                this.Width *= 1.25;
            }

            if(control.Tag is string) this.Title = control.Tag.ToString();
            this.Panel.Children.Add(control);
        }
    }
}
